<template>
  <div class="about">
    <h1>This is an about page</h1>
    <button @click="addClick">添加数据</button>
  </div>
</template>
<script>
// import axios from "axios";
import fetch from "../api/fetch";
export default {
  mounted() {
    this.getData();
  },
  methods: {
    getData() {
      fetch
        .post("/api/login", {
          username: "devin",
          password: 123
        })
        .then(res => {
          if (res.data.code == 0) {
            console.log(res.data.token, "登陆接口");
            sessionStorage.setItem("token", res.data.token);
          }
        });
    },
    addClick() {
      fetch.get("/api/page").then(res => {
        console.log(res, "res");
      });
      // axios
      //   .get("http://localhost:3000/api/page", {
      //     headers: {
      //       authorization: sessionStorage.getItem("token")
      //     }
      //   })
      //   .then(res => {
      //     console.log(res, "res");
      //   });
    }
  }
};
</script>
